package models

import (
	"gorm.io/gorm"
	"time"
)

type VoucherOrder struct {
	gorm.Model
	Id         int    `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
	UserId     int    `gorm:"column:user_id" json:"userId"`
	VoucherId  int    `gorm:"column:voucher_id" json:"voucherId"`
	PayType    int    `gorm:"column:pay_type;default:1" json:"payType"`
	Status     int    `gorm:"column:status;default:1" json:"status"`
	PayTime    MyTime `gorm:"column:pay_time" json:"payTime"`
	UseTime    MyTime `gorm:"column:use_time" json:"useTime"`
	RefundTime MyTime `gorm:"column:refund_time" json:"refundTime"`
}

type VoucherOrderVo struct {
	gorm.Model
	Id         int    `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
	UserId     int    `gorm:"column:user_id" json:"userId"`
	VoucherId  int    `gorm:"column:voucher_id" json:"voucherId"`
	PayType    int    `gorm:"column:pay_type" json:"payType"`
	Status     int    `gorm:"column:status" json:"status"`
	CreateTime MyTime `gorm:"column:created_at" json:"createTime"`
	PayTime    MyTime `gorm:"column:pay_time" json:"payTime"`
	UseTime    MyTime `gorm:"column:use_time" json:"useTime"`
	RefundTime MyTime `gorm:"column:refund_time" json:"refundTime"`
	UpdateTime MyTime `gorm:"column:updated_at" json:"updateTime"`
}

func (VoucherOrder) TableName() string {
	return "tb_voucher_order"
}
func (VoucherOrderVo) TableName() string {
	return "tb_voucher_order"
}
func (vo *VoucherOrder) BeforeCreate(scope *gorm.DB) error {
	vo.PayTime = MyTime(time.Now())
	return nil
}
